﻿//===================================================================================
// Copyright (c) Ryan Garrett.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===================================================================================

using System;

namespace Caffeine.Core.Test.TestModel
{
    public class ModelForCommandRegistrationTest : ModelBase
    {
        private readonly ModelCommand<String> _stringCommand;
        private readonly ModelCommand<Object> _objectCommand;
        private readonly ModelCommand<Int32> _int32Command;
        private readonly ModelCommand<Char> _charCommand;
        private readonly ModelCommand<Nullable<Int32>> _nullableInt32Command;
        private readonly ModelCommand<Nullable<Char>> _nullableCharCommand;
        private readonly ModelCommand<String[]> _stringArrayCommand;
        private readonly ModelCommand<Char[]> _charArrayCommand;
        private readonly ModelCommand<Nullable<Int32>[]> _nullableInt32ArrayCommand;
        private readonly ModelCommand<TestStruct> _structCommand;

        public Boolean ObjectCommandCanExecute
        {
            get;
            set;
        }

        public ModelForCommandRegistrationTest()
        {
            ObjectCommandCanExecute = true;
            _stringCommand = RegisterCommand<String>(OnStringCommand);
            _objectCommand = RegisterCommand<Object>(OnObjectCommand, CanObjectCommandExecute);
            _int32Command = RegisterCommand<Int32>((p1, p2) => { });
            _charCommand = RegisterCommand<Char>((p1, p2) => { }, (p1, p2) => { return false; });
            _nullableInt32Command = RegisterCommand<Nullable<Int32>>((p1, p2) => { });
            _nullableCharCommand = RegisterCommand<Nullable<Char>>((p1, p2) => { }, (p1, p2) => { return false; });
            _stringArrayCommand = RegisterCommand<String[]>((p1, p2) => { });
            _charArrayCommand = RegisterCommand<Char[]>((p1, p2) => { }, (p1, p2) => { return true; });
            _nullableInt32ArrayCommand = RegisterCommand<Nullable<Int32>[]>((p1, p2) => { }, (p1, p2) => { return true; });
            _structCommand = RegisterCommand<TestStruct>((p1, p2) => { });
        }

        public ModelCommand<String> StringCommand
        {
            get
            {
                return _stringCommand;
            }
        }

        public ModelCommand<Object> ObjectCommand
        {
            get
            {
                return _objectCommand;
            }
        }

        public ModelCommand<Int32> Int32Command
        {
            get
            {
                return _int32Command;
            }
        }

        public ModelCommand<Char> CharCommand
        {
            get
            {
                return _charCommand;
            }
        }

        public ModelCommand<Nullable<Int32>> NullableInt32Command
        {
            get
            {
                return _nullableInt32Command;
            }
        }

        public ModelCommand<Nullable<Char>> NullableCharCommand
        {
            get
            {
                return _nullableCharCommand;
            }
        }

        public ModelCommand<String[]> StringArrayCommand
        {
            get
            {
                return _stringArrayCommand;
            }
        }

        public ModelCommand<Char[]> CharArrayCommand
        {
            get
            {
                return _charArrayCommand;
            }
        }

        public ModelCommand<Nullable<Int32>[]> NullableInt32ArrayCommand
        {
            get
            {
                return _nullableInt32ArrayCommand;
            }
        }

        public ModelCommand<TestStruct> StructCommand
        {
            get
            {
                return _structCommand;
            }
        }

        public void OnStringCommand(ModelBase parent, String parameter)
        {
        }

        public void OnObjectCommand(ModelBase parent, Object parameter)
        {
        }

        public Boolean CanObjectCommandExecute(ModelBase parent, Object parameter)
        {
            return ObjectCommandCanExecute;
        }
    }
}
